'''
unzip job.

Licensed under the GPL.

@author: screwdriver
'''

'''
Version history:
----------------
2009-03-29 screwdirver Created.
'''

import os;

from commandlinetool import ExcecuteCommand;
from commandlinetool import CommandLine;
from commandlinetool import Option;

class Unzipper(ExcecuteCommand):
	'''
	Unzip job.
	'''
	
	__UNZIP_TOOL = "unzip";
	
	__ORIGIN_OPTION = "o";
	__DESTINATION_OPTION = "d";
	
	def __buildCommand(self, terragearRoot, origin, destination):
		
		tool = terragearRoot +  "/" + Unzipper.__UNZIP_TOOL;
		command = CommandLine(tool);
		
		originOption = Option(Unzipper.__ORIGIN_OPTION, origin);
		originOption.prefix = Option.PREFIX_DASH_SHORT;
		command.options.append(originOption);

		destinationOption = Option(Unzipper.__DESTINATION_OPTION, destination);
		destinationOption.prefix = Option.PREFIX_DASH_SHORT;
		command.options.append(destinationOption);
		
		return command;


	def __init__(self, terragearRoot, origin, destination, logName):
		
		command = self.__buildCommand(terragearRoot, origin, destination);
		
		commandline = str(command);
		
		ExcecuteCommand.__init__(self, commandline, "./logs/unzip." + logName);
		
		